from selenium import webdriver
import time


driver = webdriver.Firefox()
driver.get("http://bj.58.com")
zufang = driver.find_element_by_xpath('//*[@id="fcNav"]/em/a[1]')
zufang.click()

# 进入到租房页面
# NoSuchElementException: Message: Unable to locate element: /html/body/div[5]/div[2]/div[2]/dl[1]/dd/a[4]

# changping = driver.find_element_by_xpath('/html/body/div[5]/div[2]/div[2]/dl[1]/dd/a[4]')
# changping.click()

# 需要切换窗口
# 拿到窗口的句柄
windows = driver.window_handles
# 切换窗口
# driver.switch_to_window()
driver.switch_to.window(windows[1])
time.sleep(3)
changping = driver.find_element_by_xpath('/html/body/div[5]/div[2]/div[2]/dl[1]/dd/a[4]')
changping.click()
driver.find_element()